package com.zhl.hadoop.cases.joincase;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-10-30 17:49
 **/
public class JoinReducer extends Reducer<Text,Text,Text,Text> {
	@Override
	protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
		String valStr = "";
		String perfix = "";
		for(Text t : values){
			String tv = t.toString();
			if(tv.startsWith("2020")){
				perfix = tv;
			}else {
				valStr += "\t" + tv;
			}
		}
		context.write(key,new Text(perfix+valStr));
	}
}
